﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SendProblem.aspx.cs" Inherits="Page_AutoRun_SendProblem" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>报修信息</title>
    <%--layui--%>
    <link href="../../layui/css/layui.css" rel="stylesheet" />
    <script src="../../layui/layui.js"></script>

    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script src="../../Scripts/jquery.form.js"></script>
    <script src="../../layui/ajaxfileupload.js"></script>
    <style>
        .right span {
            display: inline-block;
            width: 22px;
            height: 22px;
            margin-left: 5px;
            background: url("/images/star-no.png") no-repeat 0 0;
            background-size: 22px;
        }

        .right .star-icon {
            background: url("/Images/star-at.png") no-repeat 0 0;
            background-size: 22px;
        }
    </style>
</head>
<body>
    <%if (dtorderModel != null)
        {%>
    <form class="layui-form" action="" id="AddForm" style="padding-right: 10px; padding-top: 10px;" enctype="multipart/form-data" method="post">

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">当前处理人</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" autocomplete="off" disabled class="layui-input" id="name" value="<%=Jieshouren %>" />
            </div>
        </div>

        <% if (!string.IsNullOrEmpty(dtorderModel.solve_time))
            {%>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">延迟处理</label>
            <div class="layui-input-block">
                <input type="text" name="yctime1" lay-verify="required" autocomplete="off" disabled class="layui-input" id="yctime1" value="<%=dtorderModel.solve_time %>" />
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">延迟原因</label>
            <div class="layui-input-block">
                <textarea disabled class="layui-textarea"><%=dtorderModel.mark %></textarea>
            </div>
        </div>
        <% } %>


        <input type="hidden" class="orderId" value="<%=dtorderModel.id %>" />
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="required" autocomplete="off" disabled class="layui-input" id="title" value="<%=dtorderModel.title %>" />
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">类别</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" id="type" runat="server" lay-search="">
                </select>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 15px;">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="text" name="state" lay-verify="required" autocomplete="off" disabled class="layui-input" id="state" value="<%=State %>" />
            </div>
        </div>
        <% if (dtorderModel.state == 2)
            { %>
        <div class="layui-form-item" style="margin-top: 15px;">
            <label class="layui-form-label">驳回原因</label>
            <div class="layui-input-block">
                <textarea disabled id="reason" class="layui-textarea"><%=dtorderModel.mark %></textarea>
            </div>
        </div>
        <%} %>


        <div class="layui-form-item">
            <label class="layui-form-label">报修时间</label>
            <div class="layui-input-block">
                <input type="text" name="time" lay-verify="required" autocomplete="off" disabled class="layui-input" id="time" value="<%=dtorderModel.add_time %>" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">工号</label>
            <div class="layui-input-block">
                <input type="text" name="card" lay-verify="required" autocomplete="off" disabled class="layui-input" id="card" value="<%=dtorderModel.number %>" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">优先级</label>
            <div class="layui-input-block">
                <input type="checkbox" name="like[read]" title="<%=dtorderModel.priority == 0 ? "普通" : dtorderModel.priority == 1 ? "重要" : "紧急" %>" checked="" />
                <div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin=""><span><%=dtorderModel.priority == 0 ? "普通" : dtorderModel.priority == 1 ? "重要" : "紧急" %></span><i class="layui-icon"></i></div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" autocomplete="off" disabled class="layui-input" id="name" value="<%=dtorderModel.name %>" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="phone" lay-verify="required" autocomplete="off" disabled class="layui-input" id="phone" value="<%=dtorderModel.telephone %>" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">报修地址</label>
            <div class="layui-input-block">
                <input type="text" name="address" lay-verify="required" autocomplete="off" disabled class="layui-input" id="address" value="<%=dtorderModel.address %>" />
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">固定资产号</label>
            <div class="layui-input-block">
                <input type="text" name="address" autocomplete="off" disabled class="layui-input" id="address" value="<%=string.IsNullOrEmpty(dtorderModel.fixedAssets)?"无":dtorderModel.fixedAssets %>" />
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">问题描述</label>
            <div class="layui-input-block">
                <textarea name="details" disabled class="layui-textarea"><%=dtorderModel.details %></textarea>
            </div>
        </div>
        <%if (!string.IsNullOrEmpty(dtorderModel.img_url))
            {%>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">故障图片</label>
            <div class="layui-input-block">
                <img src="http://www.healthyperson.cn:8090/<%=dtorderModel.img_url %>" width="200px" height="200px" />
            </div>
        </div>
        <% } %>

        <div class="layui-form-item">
            <label class="layui-form-label">解决图片</label>
            <div class="layui-input-block">
                <%--<input type="file" name="file" class="layui-upload-file" lay-ext="jpg|png|gif" lay-title="添加一个解决完成图片">--%>
                <input type="file" id="file1" name="file" /><br />
                <input type="button" class="shangchuan" value="上传" />
            </div>
        </div>
        <%if (!string.IsNullOrEmpty(dtorderModel.solveImg))
            {%>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <img class="problemImg" src="http://www.healthyperson.cn<%=dtorderModel.solveImg %>" width="200px" height="200px" />
            </div>
        </div>
        <% } %>

        <%if (dtorderModel.state > 0 && dtorderModel.state != 2)
            {%>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">工单评分</label>
            <div class="layui-input-block">
                <span class="right" style="line-height: 36px;">
                    <span class="star-status"></span>
                    <span class="star-status"></span>
                    <span class="star-status"></span>
                    <span class="star-status"></span>
                    <span class="star-status"></span>
                </span>
                <input type="hidden" name="txtStarLevel" id="StarLevel" class="star-status" value="0" />
            </div>
        </div>
        <% } %>
        <div class="layui-form-item">
            <div class="layui-input-block" id="problemImgDiv" style="display: none">
                <img class="problemImg" src="" width="200px" height="200px" />
            </div>
        </div>

        <div class="layui-form-item" id="buttonfrom">
            <div class="layui-input-block" style="margin-left: 50px;">
                <div>
                    <button class="layui-btn" id="qiangdan" lay-submit="" lay-filter="formDemo">抢单</button>
                    <span class="layui-btn" id="bohui">驳回</span>
                </div>
                <div style="margin-top: 5px;">
                    <span class="layui-btn" id="alertType">更改类别</span>
                    <% if (dtorderModel.state == 1)
                        {%>
                    <span class="layui-btn" id="yc">延迟处理</span>
                    <% } %>
                </div>

            </div>
        </div>


    </form>
    <% }
        else
        {%>
    <div class="no_record noneData" style="text-align: center; margin: 30px auto 10px;">
        <div>
            <img src="../../Images/no-data-icon.png" /><br>
            无报修记录
        </div>
    </div>
    <%} %>

    <%--    <p>
        <input type="file" id="file1" name="file" /><input type="button" value="上传" />
    </p>
    
    <p>
        <img id="img1" alt="上传成功啦" src="" />
    </p>--%>

    <script>

        //表单提交完成
        function showResponse(data, status) {
            if (data.status == 1) {
                layer.msg(data.info, {
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                }, function () {
                    //window.location = "SendProblem.aspx?Id=" +<%=Id%> + "&cardId=" + <%=cardId%>;
                    location.href = "SendProblem.aspx?Id=" +<%=Id%> + "&cardId=" + <%=cardId%>+"&time="+((new Date()).getTime());
                });

            }
            else {
                layer.msg(data.info, {
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        }



        //Demo
        layui.use('form', function () {
            var form = layui.form();

            //监听提交
            form.on('submit(formDemo)', function (data) {
                var OrderId = $(".orderId").val();
                var star = $("#StarLevel").val();
                var option = {
                    dataType: 'json',
                    url: '/Handler/TestHandler.ashx?Action=GetOrderInfo&OrderId=' + OrderId + '&cardId=<%=cardId%>&star='+star,
                    success: showResponse,
                    beforeSubmit: function(a) {
                        if (<%=ProblemState%> == 4&&star<=0) {
                            layer.msg("请给工单打分", {
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）

                            });
                            return false;
                        }

                    }
                };
                $('#AddForm').ajaxForm(option);
            });
            <%--form.on('submit(formDemo1)', function (data) {
                
                var OrderId = $(".orderId").val();
                var option = {
                    dataType: 'json',
                    url: '/Handler/TestHandler.ashx?Action=ProblemBoHui&OrderId=' + OrderId + '&cardId=<%=cardId%>',
                    success: showResponse
                };
                $('#AddForm').ajaxForm(option);
            });--%>

        });
        layui.use('upload', function () {
            layui.upload({
                url: '/Handler/UploadHandler.ashx?action=UploadSolveImage&Id=<%=Id%>'
                , method: 'post' //上传接口的http类型
                , success: function (res) {
                    if (res.success == false) {
                        layer.msg(res.msg, {
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        });
                    } else {
                        $(".problemImg").attr('src', res.msg);
                        $("#problemImgDiv").show();
                    }

                }
            });
        });
        layui.use('laydate', function() {
            var laydate = layui.laydate;
        });
      

        $(function () {
            $("#type").val(<%=typeVal%>);
            if (<%=ProblemState%>==1) {
                $("#qiangdan").text("处理完成");
            }
            if (<%=ProblemState%>==4) {
                $("#qiangdan").text("已处理完成,关闭工单");
            }
            if (<%=ProblemState%>==3) {
                $("#qiangdan").text("该工单已关闭");
                $("#bohui").hide();
            }
            if (<%=ProblemState%>==2) {
                $("#buttonfrom").hide();
            }

            if (<%=ProblemState%>==4||<%=ProblemState%>==3) {
                $("#bohui").hide();
                $("#alertType").hide();
            }
            $(".shangchuan").click(function () {
                ajaxFileUpload();
            });

            if (<%=StarNum%> >= 0) {
                var num = <%=StarNum%>;
                $(".right span").each(function (i, e){//所有的span标签
                    if (i < num ) {
                        $(this).addClass("star-icon");
                    } //当前文本内容
                });
            }

            ////星级
            //$("body").on("click", ".star-status", function () {
            //    var index = $(this).index();
            //    $("span", this.parentNode).each(function (i, e) {
            //        i <= index ? $(this).addClass("star-icon") : $(this).removeClass("star-icon");

            //    });
            //    $("input", this.parentNode.parentNode).val(index + 1);
            //});
            $(".star-status").click(function() {

                var index = $(this).index();
                $("span", this.parentNode).each(function (i, e) {
                    i <= index ? $(this).addClass("star-icon") : $(this).removeClass("star-icon");

                });
                $("input", this.parentNode.parentNode).val(index + 1);
            });

            //监听提交驳回
            $("#bohui").click(function() {
                //    layer.open({
                //        title: '驳回'
                //        ,content: '<div>驳回原因：<textarea placeholder="请输入驳回原因" class="layui-textarea"></textarea></div>'
                //    }); 
                layer.confirm('<div>驳回原因：<textarea placeholder="请输入驳回原因" id="reason" class="layui-textarea"></textarea></div>', { title:'提示',btn: ['驳回','取消'], //按钮
                    shade: [0.5, '#393D49'] }, function(index) {
                        var orderId = $(".orderId").val();
                        var reason = $("#reason").val();
                        if ($.trim(reason)==""){
                            layer.msg("请填写驳回原因", {
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            });
                            return;
                        }
                        $.post("/Handler/TestHandler.ashx?Action=ProblemBoHui", { OrderId: orderId, cardId: <%=cardId%>,mark: reason}, function(data) {
                            var list = eval("(" + data + ")");
                            if (list.status == 1) {
                                layer.msg(list.info, {
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                    window.location.reload();
                                });
                            }
                            else {
                                layer.msg(list.info, {
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                });
                            }
                        });
                    });
            });

            //延迟处理
            $("#yc").click(function() { 
                layer.confirm('<div>延迟处理：<input class="layui-input" readonly placeholder="开始处理时间" id="yctime" onclick="layui.laydate({elem: this, festival: true})">延迟原因：<textarea placeholder="请输入延迟原因" id="reason" class="layui-textarea"></textarea></div>', { title:'提示',btn: ['确定','取消'], //按钮
                    shade: [0.5, '#393D49'] }, function(index) {
                        var orderId = $(".orderId").val();
                        var reason = $("#reason").val();
                        var yctime = $("#yctime").val();
                        if (yctime=="" || $.trim(reason)=="") {
                            layer.msg("请填写延迟信息", {
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            });
                            return;
                        }
                        $.post("/Handler/TestHandler.ashx?Action=ProblemYanChi", { OrderId: orderId,mark: reason,yctime : yctime}, function(data) {
                            var list = eval("(" + data + ")");
                            if (list.status == 1) {
                                layer.msg(list.info, {
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                    window.location.reload();
                                });
                            }
                            else {
                                layer.msg(list.info, {
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                });
                            }
                        });
                    });
            });

            //监听更改类别
            $("#alertType").click(function() {
                layer.confirm('确定更改类别么？', {icon: 3, title:'提示',btn: ['确定','取消'], //按钮
                    shade: false }, function(index) {
                        var typeId = $("#type").val();
                        if (typeId==0) {
                            layer.msg("请选择类别", {
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            });
                            return;
                        }
                        var orderId = $(".orderId").val();
                        $.post("/Handler/TestHandler.ashx?Action=ProblemTypeAlert", { OrderId: orderId, cardId: <%=cardId%>,typeId :typeId }, function(data) {
                            var list = eval("(" + data + ")");
                            if (list.status == 1) {
                                layer.msg(list.info, {
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                    window.location.reload();
                                });

                            }
                            else {
                                layer.msg(list.info, {
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                });
                            }
                        });
                    });
            });
            
        });
            function ajaxFileUpload() {
                $.ajaxFileUpload
                (
                    {
                        url: '/Handler/UploadHandler.ashx?action=UploadSolveImage&Id=<%=Id%>', //用于文件上传的服务器端请求地址
                        secureuri: false, //是否需要安全协议，一般设置为false
                        fileElementId: 'file1', //文件上传域的ID
                        dataType: 'json', //返回值类型 一般设置为json
                        success: function (data, status) //服务器成功响应处理函数
                        {
                            if (data.success == false) {
                                alert(data.msg);
                            } else {
                                $(".problemImg").attr('src', data.msg);
                                $("#problemImgDiv").show();
                            }
                        },
                        error: function (data, status, e) //服务器响应失败处理函数
                        {
                            alert(e);
                        }
                    }
            );
                return false;
            }


    </script>
</body>
</html>



